#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2020-11-03 8:50 上午
# @Author  : yangdy
# @File    : 2020-11-03.941.有效的山脉数组
# @Software: PyCharmCE
from tools.my_methods import *


class Solution:
    def validMountainArray(self, A: List[int]) -> bool:
        c = 0
        for i in range(1, len(A)-1):
            if A[i-1] < A[i] > A[i+1]:
                c += 1
                if c > 1:
                    return False
            if A[i-1] > A[i] < A[i+1]:
                return False
            if A[i-1] == A[i] or A[i] == A[i+1]:
                return False
        return c > 0
